package prefuse.treeview;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import javax.swing.BorderFactory;
import javax.swing.JColorChooser;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class JFrameWin extends JPanel implements ChangeListener{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static JColorChooser colorChooser;
	private JLabel banner;
	 public static Color color;

	public JFrameWin() {
		super(new BorderLayout());
		JPanel bannerPanel = new JPanel(new BorderLayout());
		bannerPanel.setBorder(BorderFactory
				.createTitledBorder("chooser Text color"));
		colorChooser = new JColorChooser(Color.red);
		// add(bannerPanel,BorderLayout.CENTER);
		add(colorChooser, BorderLayout.PAGE_END);
		
		  colorChooser.getSelectionModel().addChangeListener(this);
	}
	
	public static Color costomColor(){
		return color;
	}

	public static void main(String[] args) {
		JFrame frame = new JFrame("choose color");
		frame.setBounds(200, 200, 400, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
		JComponent newContentPane = new JFrameWin();
		newContentPane.setOpaque(true);
		frame.setContentPane(newContentPane);
		frame.pack();
	}

	@Override
	public void stateChanged(ChangeEvent arg0) {
		// TODO Auto-generated method stub
		 	color = colorChooser.getColor();
	        System.out.println("hahaha " + color);
	}
}